
package Pro;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;


public class mark {
    //o day ta tinh diem theo chu ki, neu nhu trong vong 1 phut thi duoc 10x , 2 phut con 9x....
    public static int[] getmark_ofplayer(int second, String opfinish, int puid)
    {
        int[] kq=new int[3];
        try {
            //String type=pro_database.edit_detail_4.get_type(opfinish)
           PreparedStatement st=Connect.Connect.Con().prepareStatement("select * from Pu_Question where PuzzleID=?");
           st.setInt(1, puid);
           ResultSet set=st.executeQuery();
           int cau_dung=0;
           int tongcau=0;
           while(set.next())
           {
                String[] po=set.getString(6).split("-");
                String[] userchoose=opfinish.split("-");
                String uAns="";
                for (int i = 0; i < po.length; i++) {
                    uAns=uAns+userchoose[new Integer(po[i])-1];
                }
                if(set.getString(4).equalsIgnoreCase(uAns))
                {
                    cau_dung++;
                }
                tongcau++;
           }
           int muli=0;
           if(second<60)
           {
             muli=10;
           }else if(second<120)
           {
            muli=9;
           }else if(second<180)
           {
            muli=8;
           }else if(second<180)
           {
            muli=7;
           }else if(second<240)
           {
            muli=6;
           }else if(second<300)
           {
            muli=5;
           }else if(second<360)
           {
            muli=4;
           }else if(second<420)
           {
            muli=3;
           }else if(second<480)
           {
            muli=2;
           }else
           {
            muli=1;
           }
           int markforeachque=100/tongcau;
           int mark_non=markforeachque*cau_dung;
           kq[0]=mark_non*muli;
           kq[1]=tongcau;
           kq[2]=cau_dung;
        } catch (SQLException ex) {
            Logger.getLogger(mark.class.getName()).log(Level.SEVERE, null, ex);
        }
        return kq;
    }
}
